package ${basepackage}.framework.base.controller;

import java.beans.PropertyEditorSupport;
import java.sql.Date;
import java.text.SimpleDateFormat;

import ${basepackage}.framework.base.util.AppConstant;

<#include "/author.include">
public class DateEditor extends PropertyEditorSupport {

	 public String getAsText() {
	  Date value = (Date) getValue();
	  if(null == value){
	   return "";
	  }
	  SimpleDateFormat df =new SimpleDateFormat(AppConstant.DEFAULT_DATE_FORMAT);
	  return df.format(value);
	 }

	 public void setAsText(String text) throws IllegalArgumentException {
		Date value = null;
		  if(null != text && !text.equals("")){
	   SimpleDateFormat df =new SimpleDateFormat(AppConstant.DEFAULT_DATE_FORMAT);
	   try{
	    value = new Date(df.parse(text).getDate());
	   }catch(Exception e){
	    e.printStackTrace();
	   }
	  }
	  setValue(value);
	 }
	}

